-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add SymPy plugin #186
add SymPy plugin #186
Conversation
Depending on if the (I'm not a maintainer, just someone who has done this before) |
Hmm, I see. Could you please comment on #185 in that case? The problem is that people might want to avoid pulling in all dependencies of Latexify.jl and the official recipe system using a macro doesn't work with Requires.jl. |
And I don't think glue packages are a good solution. If I want to use two packages together, I don't want to depend on a third one. |
SymPy just needs to add the recipe to their package and then everything is 👍 |
I was just working on a comment, but it took a while because I can't figure out |
Okay, let's say I prepare a PR to SymPy.jl using Trying to mimic the SymEngine plugin by converting a julia> using SymPy, Latexify
julia> α = SymPy.symbols("α")
α
julia> @latexrecipe function _(x::Sym)
string(x)
end
julia> latexify(- 3/(8*α) + 1/(8*α^2))
ERROR: MethodError: no method matching get(::Char, ::Symbol, ::Symbol)
Closest candidates are:
get(::PyCall.PyDict{K, V}, ::Any, ::Any) where {K, V} at /home/hendrik/.julia/packages/PyCall/BD546/src/conversions.jl:496
get(::IOContext, ::Any, ::Any) at show.jl:343
get(::NamedTuple, ::Union{Integer, Symbol}, ::Any) at namedtuple.jl:309
...
Stacktrace:
[1] process_latexify(args::Sym; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Latexify ~/.julia/packages/Latexify/afimT/src/latexify_function.jl:21
[2] process_latexify(args::Sym)
@ Latexify ~/.julia/packages/Latexify/afimT/src/latexify_function.jl:18
[3] latexify(args::Sym; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Latexify ~/.julia/packages/Latexify/afimT/src/latexify_function.jl:3
[4] latexify(args::Sym)
@ Latexify ~/.julia/packages/Latexify/afimT/src/latexify_function.jl:2
[5] top-level scope
@ REPL[4]:1
julia> @latexrecipe function _(x::Sym)
Meta.parse(string(x))
end
julia> latexify(- 3/(8*α) + 1/(8*α^2))
ERROR: MethodError: no method matching iterate(::Expr)
Closest candidates are:
iterate(::Union{LinRange, StepRangeLen}) at range.jl:821
iterate(::Union{LinRange, StepRangeLen}, ::Integer) at range.jl:821
iterate(::T) where T<:Union{Base.KeySet{<:Any, <:Dict}, Base.ValueIterator{<:Dict}} at dict.jl:695
...
Stacktrace:
[1] indexed_iterate(I::Expr, i::Int64)
@ Base ./tuple.jl:92
[2] process_latexify(args::Sym; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Latexify ~/.julia/packages/Latexify/afimT/src/latexify_function.jl:18
[3] process_latexify
@ ~/.julia/packages/Latexify/afimT/src/latexify_function.jl:18 [inlined]
[4] latexify(args::Sym; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Latexify ~/.julia/packages/Latexify/afimT/src/latexify_function.jl:3
[5] latexify(args::Sym)
@ Latexify ~/.julia/packages/Latexify/afimT/src/latexify_function.jl:2
[6] top-level scope
@ REPL[6]:1 Do I really have to use some internal knowledge about undocumented implementation details of julia> @latexrecipe function _(x::Sym)
(string(x), ), kwargs
end
julia> latexify(- 3/(8*α) + 1/(8*α^2))
L"$\frac{-3}{8 \cdot \alpha} + \frac{1}{8 \cdot \alpha^{2}}$" Or are there other suggestions? |
Nevermind, I fixed this specific problem in #188. |
I converted this PR into a draft. As requested above, I converted the compatibility code for Latexify and SymPy into a PR to SymPy.jl. Additionally, I created a new PR #187 with a bug fix I developed while working on this PR. When these two PRs get merged, this PR can be closed. |
Closed in favor of #187 and JuliaPy/SymPy.jl#439 |
I hope this follows the recommended style. When it works, it would be really great to get a new release of Latexify.jl.